﻿using System;
using MosCraft.Utilities;
using MosCraft.Blocks;

namespace MosCraft.Terrain.WorldGen
{
    class WorldGenFlowers : WorldGenerator
    {
        private int BlockId;

        public WorldGenFlowers(int BlockID)
        {
            this.BlockId = BlockID;
        }

        public override bool generate(World world, FastRandom rand, int x, int y, int z)
        {
            for (int i = 0; i < 64; i++)
            {
                int randX = (x + rand.nextInt(8)) - rand.nextInt(8);
                int randY = (y + rand.nextInt(4)) - rand.nextInt(4);
                int randZ = (z + rand.nextInt(8)) - rand.nextInt(8);
                if (world.isAirBlock(randX, randY, randZ) &&
                    ((BlockFlower)Block.blocksList[BlockId]).canBlockStay(world, randX, randY, randZ))
                {
                    world.setBlockID(randX, randY, randZ, BlockId);
                }
            }

            return true;
        }   
    }
}
